import physgin.*;
import java.applet.Applet;
import javax.swing.*;
import java.awt.*;
import com.sun.j3d.utils.applet.JMainFrame;

public class Molecules extends Applet
{
  J3dWorld w;
  BodyController b;
  
  public static void main(String[] args)
  {
    Molecules program = new Molecules();
    JMainFrame mf = new JMainFrame(program, 500, 500);
  }
  
  Molecules()
  {
    setLayout(new BorderLayout());
    w = new J3dWorld();
      w.setBackground("background1.jpg");
    b = new BodyController(w);
    Component c = (Component) w.getCanvas();
    add(c);

                                        //position(x&y), mass, size, velocity(x&y), orientation, elasticity
    J3dBody x;
    //floor
    for (int i = 0; i < 11; i++)
    {
    x = new J3dBody("floor.jpg",Shapes.SQUARE, ((i*0.8f)-3.4f),-0.4f, 101f, 0.4f, 0f,0f, 0.0f, 0.0f);
    b.addBody(x);
    }

    //leftwall
    for (int i = 0; i < 10; i++)
    {
    x = new J3dBody("wall.jpg",Shapes.SQUARE, -3.1f,((i*0.8f) - 0.4f), 101f,0.4f, 0f,0f, 0.0f, 0.0f);
    b.addBody(x);
    }

    //rightwall
    for (int i = 1; i < 10; i++)
    {
      x = new J3dBody("wall.jpg",Shapes.SQUARE, 3.1f,((i*0.8f) - 0.4f), 101f,0.4f, 0f,0f, 0.0f, 0.0f);
      b.addBody(x);
    }
    //molecules
    for (int i = 1; i < 11; i++)
    {
      x = new J3dBody("circle.jpg",Shapes.CIRCLE, (i*0.601f)- 2.4f,0.5f, 10f,0.3f, 1.0f,0.5f, 0.0f, 0.8f);
      b.addBody(x);
    }
     for (int i = 1; i < 11; i++)
    {
      x = new J3dBody("circle.jpg",Shapes.CIRCLE, (i*0.601f)-2.4f,1.3f, 10f,0.3f, 0.0f,1.0f, 0.0f, 0.8f);
      b.addBody(x);
    }
     for (int i = 1; i < 11; i++)
    {
      x = new J3dBody("circle.jpg",Shapes.CIRCLE, (i*0.601f)-2.4f,4.3f, 10f,0.3f, 0.0f,2.0f, 0.0f, 0.8f);
      b.addBody(x);
    }
     for (int i = 1; i < 11; i++)
    {
      x = new J3dBody("circle.jpg",Shapes.CIRCLE, (i*0.601f)-2.4f,6.3f, 10f,0.3f, 0.0f,1.0f, 0.0f, 0.8f);
      b.addBody(x);
    }
       
    b.start(); 
  }
}
